package cn.flant.db.hdle.dialect;

import java.util.Map;
import java.util.Set;

import cn.flant.db.hdle.ExecuteParam;
import cn.flant.db.hdle.key.PrimaryKey;

public abstract class Dialect {

	public abstract boolean isSupportAutoGenerateKey();
	
	public String buildSelectFields(Set<String> fieldNames) {
		StringBuilder sb = new StringBuilder();
		for (String field : fieldNames) {
			if (sb.length() > 0) {
				sb.append(",");
			}
			sb.append(field);
		}
		if (sb.length() == 0) {
			return "*";
		} else {
			return sb.toString();
		}
	}

	public abstract ExecuteParam buildSelect(String selectFields, String tableName, String[] fields, Object[] params);

	public abstract ExecuteParam buildSave(String tableName, PrimaryKey pkInfo, Map<String, Object> values);

	public abstract ExecuteParam buildUpdate(String tableName, Map<String, Object> setParams, Map<String, Object> keyParams);

	public abstract ExecuteParam buildDelete(String tableName, String[] fields, Object[] params);

	public abstract String buildPageSql(String selectSql, int pageSize, int pageNo);
}
